package detect.parse.tree.token;

public class PositionString {
	public String str="";	
	public int beginPosition=0;
	
	public int length(){
		return str.length();
	}
	
	public PositionString(String _str,int _beginPosition){
		str=_str;
		beginPosition=_beginPosition;
	}
	
	public PositionString subRelatedString(int fromIndex,int toIndex){
		return new PositionString(str.substring(fromIndex,toIndex),
									beginPosition+fromIndex);
	}
	public PositionString subAbsoluteString(int fromIndex,int toIndex){
		return new PositionString(str.substring(fromIndex,toIndex),
									beginPosition+fromIndex);
	}
	
	@Override
	public String toString(){
		return str;
	}
	
	@Override
	public boolean equals(Object obj){
		if(obj instanceof PositionString){
			PositionString psStr=(PositionString)obj;
			return psStr.str.equals(psStr.str);
		}
		return false;
	}
	
}
